package ihm;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

import buttonEvent.AddListener;
import buttonEvent.ClearListener;
import buttonEvent.ComputeListener;

public class Fenetre extends JFrame{
	/**
	 * 
	 */
	private static final long serialVersionUID = 5823415086493369269L;
	Dessin pan;
	public Dessin getPan() {
		return pan;
	}

	JPanel container;
	JButton add;
	JButton clear;
	JButton compute;
	JTextField apercu;
	
	public JTextField getApercu() {
		return apercu;
	}

	public void setApercu(JTextField apercu) {
		this.apercu = apercu;
	}

	public Fenetre(String title){
		this.setResizable(false);
		container= new JPanel();
		this.setLayout(new BorderLayout());
		container.setLayout(new GridLayout(4,1));
		add = new JButton("Add");
		clear = new JButton("Clear");
		compute = new JButton("Compute");
		apercu = new JTextField("apercu");
		apercu.setEditable(false);
		container.add(add);
		container.add(clear);
		container.add(compute);
		container.add(apercu);
		pan = new Dessin();
		pan.setBackground(Color.WHITE);
		this.add(container,BorderLayout.EAST);
		this.add(pan,BorderLayout.CENTER);
		this.setTitle(title);
		this.setSize(200, 200);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
		compute.addActionListener(new ComputeListener(this));
		add.addActionListener(new AddListener(this,apercu.getText()));
		clear.addActionListener(new ClearListener(this));
		
	}

}

